package km.TestFileExplorer;

import java.io.*;
import java.net.*;
import java.util.*;

import android.util.*;
import android.webkit.*;

public class FileManager {
    /**
     * 웹으로 첨부 파일리스트 전송
     * @param fnames
     * @param fpaths
     */
    public static void addFile(WebView wv,ArrayList<String> fnames, ArrayList<String> fpaths){
//    	wv.loadUrl("javascript:addFile('"+M_Util.putJSONArray(fnames, fpaths)+"')");        	
    }
    

	/**
	 * Url encoding (get방식)  //현재안씀
	 * @param httpUrl
	 * @return
	 */
	public String encodeParam(String httpUrl){
		String url ="";
		StringBuffer body = new StringBuffer();
		try {
		int pos = httpUrl.indexOf("?");
//		int paramPos = httpUrl.indexOf("&");
		String param = "";
		if (pos != -1) {
			url = httpUrl.substring(0, pos);
			param = httpUrl.substring(pos + 1);			
			String[] params = param.split("&");
			for (int i = 0; i < params.length; i++) {
				final String keyvalue = params[i];
				if(!"".equals(keyvalue)){
					int po = keyvalue.indexOf((String) ("="));
					String divider = i<1?"?":"&";
					if (param.length() > po + 1)
						body.append(divider + keyvalue.substring(0, po) + "=" + URLEncoder.encode(new String(keyvalue.substring(po + 1).getBytes("euc-kr"), "8859_1")));
					else
						body.append(divider + keyvalue.substring(0, po) + "=");
				}
			}
			url+=body;	
		}else
			url = httpUrl;
		Log.e("url",url);
		Log.e("body",body.toString());
	} catch (UnsupportedEncodingException e) {
		e.printStackTrace();
		url = httpUrl;
	}
		return url;
	}
	

}
